<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
    />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <link rel="stylesheet" href="/umi.css" />
    <script>
      window.routerBase = "/";
    </script>
    <script>
      //! umi version: 3.3.7
    </script>
    <title>快速开始</title>
  </head>
  <body>
    <div id="root"><div class="__dumi-default-layout" data-route="/guide/start" data-show-sidemenu="true" data-show-slugs="true" data-site-mode="true" data-gapless="false"><div class="__dumi-default-navbar" data-mode="site"><button class="__dumi-default-navbar-toggle"></button><a class="__dumi-default-navbar-logo" style="background-image:url(&#x27;./images/homebrew-256x256.png&#x27;)" href="/">Homebrew</a><nav><div class="__dumi-default-search"><input type="search" class="__dumi-default-search-input" value=""/><ul></ul></div><span><a aria-current="page" class="active" href="/guide">指南</a></span><span><a target="_blank" rel="noopener noreferrer" href="https://github.com/ineo6/homebrew-install">GitHub<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="__dumi-default-external-link-icon"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></span></nav></div><div class="__dumi-default-menu" data-mode="site"><div class="__dumi-default-menu-inner"><div class="__dumi-default-menu-header"><a class="__dumi-default-menu-logo" style="background-image:url(&#x27;./images/homebrew-256x256.png&#x27;)" href="/"></a><h1>Homebrew</h1><p></p></div><div class="__dumi-default-menu-mobile-area"><ul class="__dumi-default-menu-nav-list"><li><a aria-current="page" class="active" href="/guide">指南</a></li><li><a target="_blank" rel="noopener noreferrer" href="https://github.com/ineo6/homebrew-install">GitHub<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="__dumi-default-external-link-icon"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div><ul class="__dumi-default-menu-list"><li><a target="_blank" rel="noopener noreferrer">介 绍</a><ul><li><a href="/guide"><span>介 绍</span></a></li><li><a href="/guide/how-it-works"><span>如何工作的？</span></a></li><li><a aria-current="page" class="active" href="/guide/start"><span>快速开始</span></a></li></ul></li><li><a href="/guide/m1">M1芯片 </a></li><li><a href="/guide/faq">FAQ</a></li></ul></div></div><ul role="slug-list" class="__dumi-default-layout-toc"><li title="安装说明" data-depth="2"><a href="/guide/start#安装说明"><span>安装说明</span></a></li><li title="设置镜像" data-depth="2"><a href="/guide/start#part3"><span>设置镜像</span></a></li><li title="中科大源" data-depth="3"><a href="/guide/start#中科大源"><span>中科大源</span></a></li><li title="清华大学源" data-depth="3"><a href="/guide/start#清华大学源"><span>清华大学源</span></a></li><li title="设置bottles镜像" data-depth="3"><a href="/guide/start#设置bottles镜像"><span>设置bottles镜像</span></a></li><li title="恢复默认源" data-depth="3"><a href="/guide/start#恢复默认源"><span>恢复默认源</span></a></li><li title="如何卸载Homebrew" data-depth="2"><a href="/guide/start#如何卸载homebrew"><span>如何卸载Homebrew</span></a></li><li title="其他相关" data-depth="2"><a href="/guide/start#其他相关"><span>其他相关</span></a></li><li title="cask" data-depth="3"><a href="/guide/start#cask"><span>cask</span></a></li><li title="反馈" data-depth="2"><a href="/guide/start#反馈"><span>反馈</span></a></li><li title="如果对您有帮助" data-depth="2"><a href="/guide/start#如果对您有帮助"><span>如果对您有帮助</span></a></li><li title="参考文章" data-depth="2"><a href="/guide/start#参考文章"><span>参考文章</span></a></li></ul><div class="__dumi-default-layout-content"><div class="markdown"><h1 id="快速开始"><a aria-hidden="true" tabindex="-1" href="/guide/start#快速开始"><span class="icon,icon-link"></span></a>快速开始</h1><p>如果你是在<code>M1</code>芯片的<code>Mac</code>上安装<code>Homebrew</code>，请参考 <a href="/guide/m1">M1芯片安装教程</a>。</p><h2 id="安装说明"><a aria-hidden="true" tabindex="-1" href="/guide/start#安装说明"><span class="icon,icon-link"></span></a>安装说明</h2><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token plain">/bin/bash -c </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable function">curl</span><span class="token string variable"> -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.shell</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span></div></pre></div><p>如果命令执行中卡在下面信息：</p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token operator">==</span><span class="token operator">&gt;</span><span class="token plain"> Tapping homebrew/core</span></div><div class="token-line"><span class="token plain">Cloning into </span><span class="token string">&#x27;/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core&#x27;</span><span class="token punctuation">..</span><span class="token plain">.</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><p>请<code>Control + C</code>中断脚本执行如下命令：</p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token builtin class-name">cd</span><span class="token plain"> </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo</span><span class="token string variable">)</span><span class="token string">/Library/Taps/&quot;</span><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span><span class="token function">mkdir</span><span class="token plain"> homebrew </span><span class="token operator">&amp;&amp;</span><span class="token plain"> </span><span class="token builtin class-name">cd</span><span class="token plain"> homebrew</span></div><div class="token-line"><span class="token plain"></span><span class="token function">git</span><span class="token plain"> clone git://mirrors.ustc.edu.cn/homebrew-core.git</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><p><strong>安装<code>cask</code> 同样也有安装失败或者卡住的问题，解决方法也是一样：</strong></p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token builtin class-name">cd</span><span class="token plain"> </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo</span><span class="token string variable">)</span><span class="token string">/Library/Taps/&quot;</span><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span><span class="token builtin class-name">cd</span><span class="token plain"> homebrew</span></div><div class="token-line"><span class="token plain"></span><span class="token function">git</span><span class="token plain"> clone https://mirrors.ustc.edu.cn/homebrew-cask.git</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><p>成功执行之后继续执行安装命令。</p><p>最后看到<code>==&gt; Installation successful!</code>就说明安装成功了。</p><p>最最后更新下：</p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token plain">brew update</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><h2 id="part3"><a aria-hidden="true" tabindex="-1" href="/guide/start#part3"><span class="icon,icon-link"></span></a>设置镜像</h2><h3 id="中科大源"><a aria-hidden="true" tabindex="-1" href="/guide/start#中科大源"><span class="icon,icon-link"></span></a>中科大源</h3><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://mirrors.ustc.edu.cn/brew.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo homebrew/core</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo homebrew/cask</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain">brew update</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><h3 id="清华大学源"><a aria-hidden="true" tabindex="-1" href="/guide/start#清华大学源"><span class="icon,icon-link"></span></a>清华大学源</h3><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo homebrew/core</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo homebrew/cask</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain">brew update</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><h3 id="设置bottles镜像"><a aria-hidden="true" tabindex="-1" href="/guide/start#设置bottles镜像"><span class="icon,icon-link"></span></a>设置bottles镜像</h3><p>设置环境变量需要注意终端的类型，可以先通过以下方式获取：</p><p>执行命令<code>echo $SHELL</code>，根据结果判断：</p><ul><li><code>/bin/bash</code> =&gt; <code>bash</code> =&gt; <code>.bash_profile</code></li><li><code>/bin/zsh</code> =&gt; <code>zsh</code> =&gt; <code>.zprofile</code></li></ul><p>然后继续正式操作，以<strong>中科大源</strong>为例：</p><p>从<code>macOS Catalina</code>(10.15.x) 版开始，<code>Mac</code>使用<code>zsh</code>作为默认<code>Shell</code>，对应文件是<code>.zprofile</code>，所以命令为：</p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token builtin class-name">echo</span><span class="token plain"> </span><span class="token string">&#x27;export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles&#x27;</span><span class="token plain"> </span><span class="token operator">&gt;&gt;</span><span class="token plain"> ~/.zprofile</span></div><div class="token-line"><span class="token plain"></span><span class="token builtin class-name">source</span><span class="token plain"> ~/.zprofile</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><p>如果是<code>macOS Mojave</code> 及更低版本，并且没有自己配置过<code>zsh</code>，对应文件则是<code>.bash_profile</code>：</p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token builtin class-name">echo</span><span class="token plain"> </span><span class="token string">&#x27;export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles&#x27;</span><span class="token plain"> </span><span class="token operator">&gt;&gt;</span><span class="token plain"> ~/.bash_profile</span></div><div class="token-line"><span class="token plain"></span><span class="token builtin class-name">source</span><span class="token plain"> ~/.bash_profile</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><blockquote><p>注意：上述区别仅仅是<code>.zprofile</code>和<code>.bash_profile</code>不同，上下文如有再次提及编辑<code>.zprofile</code>，均按此方法判断具体操作的文件。</p></blockquote><p>如果想使用清华源：</p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token plain">把</span></div><div class="token-line"><span class="token plain">https://mirrors.ustc.edu.cn/homebrew-bottles</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain">替换为</span></div><div class="token-line"><span class="token plain">https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><p>至此，安装和设置操作都完成了。</p><h3 id="恢复默认源"><a aria-hidden="true" tabindex="-1" href="/guide/start#恢复默认源"><span class="icon,icon-link"></span></a>恢复默认源</h3><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://github.com/Homebrew/brew.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo homebrew/core</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://github.com/Homebrew/homebrew-core.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span><span class="token function">git</span><span class="token plain"> -C </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable">brew --repo homebrew/cask</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"> remote set-url origin https://github.com/Homebrew/homebrew-cask.git</span></div><div class="token-line"><span class="token plain"></span></div><div class="token-line"><span class="token plain">brew update</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><p><code>homebrew-bottles</code>配置只能手动删除，将 <code>~/.zprofile</code> 文件中的 <code>HOMEBREW_BOTTLE_DOMAIN=https://mirrors.xxx.com</code>内容删除，并执行 <code>source ~/.zprofile</code>。</p><h2 id="如何卸载homebrew"><a aria-hidden="true" tabindex="-1" href="/guide/start#如何卸载homebrew"><span class="icon,icon-link"></span></a>如何卸载Homebrew</h2><p>使用官方脚本同样会遇到<code>uninstall</code>地址无法访问问题，可以使用下面脚本：</p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token plain">/bin/bash -c </span><span class="token string">&quot;</span><span class="token string variable">$(</span><span class="token string variable function">curl</span><span class="token string variable"> -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall.shell</span><span class="token string variable">)</span><span class="token string">&quot;</span><span class="token plain"></span></div><div class="token-line"><span class="token plain"></span></div></pre></div><h2 id="其他相关"><a aria-hidden="true" tabindex="-1" href="/guide/start#其他相关"><span class="icon,icon-link"></span></a>其他相关</h2><h3 id="cask"><a aria-hidden="true" tabindex="-1" href="/guide/start#cask"><span class="icon,icon-link"></span></a>cask</h3><p>目前<code>cask</code>是从<code>GitHub</code>上读取软件源，而<code>GitHub Api</code>对访问有限制，如果使用比较频繁的话，可以申请<code>Api Token</code>，然后在环境变量中配置到<code>HOMEBREW_GITHUB_API_TOKEN</code>。</p><p>在<code>.zprofile</code>中追加，注意替换<code>yourtoken</code>:</p><div class="__dumi-default-code-block"><pre class="prism-code language-shell"><button class="__dumi-default-icon __dumi-default-code-block-copy-btn" data-status="ready"></button><div class="token-line"><span class="token builtin class-name">echo</span><span class="token plain"> </span><span class="token string">&#x27;export HOMEBREW_GITHUB_API_TOKEN=yourtoken&#x27;</span><span class="token plain"> </span><span class="token operator">&gt;&gt;</span><span class="token plain"> ~/.zprofile</span></div><div class="token-line"><span class="token plain"></span><span class="token builtin class-name">source</span><span class="token plain"> ~/.zprofile</span></div><div class="token-line"><span class="token plain"></span></div></pre></div><p>注意：因为<code>cask</code>是从<code>GitHub</code>下载软件，所以目前是无法加速的。</p><h2 id="反馈"><a aria-hidden="true" tabindex="-1" href="/guide/start#反馈"><span class="icon,icon-link"></span></a>反馈</h2><p>非常欢迎你来尝试使用，并提出意见，你可以通过以下方式：</p><ul><li>通过 <a target="_blank" rel="noopener noreferrer" href="https://github.com/ineo6/homebrew-install/issues">Issue<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="__dumi-default-external-link-icon"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> 报告 bug 或进行咨询</li><li>微信群(见下图)</li><li>提交 [Pull Request][pulls] 改进文档</li></ul><p><img src="https://i.loli.net/2021/01/03/sXGryYHa3JhB9QL.png" alt="湖中剑-hb.png"/></p><h2 id="如果对您有帮助"><a aria-hidden="true" tabindex="-1" href="/guide/start#如果对您有帮助"><span class="icon,icon-link"></span></a>如果对您有帮助</h2><p>分享、收藏，能让更多人能发现文章，这也是对我的认可和鼓励，谢谢。</p><h2 id="参考文章"><a aria-hidden="true" tabindex="-1" href="/guide/start#参考文章"><span class="icon,icon-link"></span></a>参考文章</h2><ul><li><a target="_blank" rel="noopener noreferrer" href="https://mirror.tuna.tsinghua.edu.cn/help/homebrew/">清华大学开源软件镜像站<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="__dumi-default-external-link-icon"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li><a target="_blank" rel="noopener noreferrer" href="http://mirrors.ustc.edu.cn/help/brew.git.html">中科大源<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="__dumi-default-external-link-icon"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div><div class="__dumi-default-layout-footer-meta"><span data-updated-text="最后更新时间：">1970-1-1 8:00:00</span></div></div></div></div>
	<script>
  window.g_useSSR = true;
  window.g_initialProps = {};
	</script>

    <script src="/umi.js"></script>
  </body>
</html>
